package com.qianfeng.test.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.qianfeng.test.R;
import com.qianfeng.test.bean.gridview_bean.MenuMain;
import com.qianfeng.test.bean.gridview_bean.NameInfo;
import com.qianfeng.test.utils.ImageLoaderHelper;

import java.util.List;

/**
 * Created by Administrator on 15-7-27.
 */
public class GridViewAdapter extends AppBaseAdapter {
    private DisplayImageOptions options;
    private List<MenuMain> list;

    public GridViewAdapter(List list, Context context) {
        super(list, context);
        this.list = list;//
    }
    //private Context context;



    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        convertView = inflater.inflate(R.layout.gridview_item_head_layout,parent,false);
        ViewHolder vh = new ViewHolder(convertView);
        vh.grid_head_textView.setText(list.get(position).getText());
        vh.grid_head_imageView.setImageResource(list.get(position).getImage());
//        vh.grid_head_imageView.setTag(list.get(position).getImage());//不懂
  //      String grid_picUrl = list.get(position).getImage();
//        ItemImageTask task = new ItemImageTask(vh.menu_item_image);
//        task.execute(menu_picUrl);
  //      ImageLoader.getInstance().displayImage(grid_picUrl,vh.grid_head_imageView,options);

        return convertView;

    }
    private static class ViewHolder {
        private ImageView grid_head_imageView;
        private TextView grid_head_textView;

        public ViewHolder(View convertView) {
            grid_head_imageView = (ImageView) convertView.findViewById(R.id.grid_head_imageView);
            grid_head_textView = (TextView) convertView.findViewById(R.id.grid_head_textView);

        }
    }
}
